package net.ermannofranco.genericdaojdbc.clause;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class PlaceholderBuilder {

	private final Map<String, Integer> namesMap = Collections
			.synchronizedMap(new HashMap<String, Integer>());

	public String getPlaceholder(String propName) {
		synchronized (namesMap) {
			Integer i = namesMap.get(propName);
			if (i == null) {
				namesMap.put(propName, 0);
				return propName + "_0";
			} else {
				int newi = i.intValue() + 1;
				namesMap.put(propName, newi);
				return propName + "_" + newi;
			}
		}
	}
}
